<template>

  <el-form :model="inputForm" ref="inputForm" v-loading="loading" label-width="120px">

    <el-tabs v-model="projectCostTab"   @tab-click="handleClick">
      
      <el-tab-pane label="成本预算表"></el-tab-pane>
      <el-tab-pane label="设备采购清单">
        <div style="margin-bottom: 10px;" v-if="!isIndex">
          <el-button @click="addCostEquipmentRow" type="primary" v-if="!isBuild">新增</el-button>
          <el-button type="primary" plain  @click="handleImport">导入</el-button>

          <el-button type="success" @click="importTemplate">下载模板</el-button>
          <el-button @click="editCostEquipmentRow" type="primary" v-if="inputForm.costEquipmentDTOList.length>0&&!isBuild">编辑</el-button>
        </div>

        <el-table class="table" size="small" :data="inputForm.costEquipmentDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="!isBuild">
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="编号">
            <template #default="{row}">
              <el-input v-model="row.listNo" placeholder="请填写编号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单名称">
            <template #default="{row}">
              <el-input v-model="row.listName" placeholder="请填写清单名称"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="品牌与型号">
            <template #default="{row}">
              <el-input v-model="row.brandModel" placeholder="请填写品牌与型号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单位">
            <template #default="{row}">
              <el-input v-model="row.unit" placeholder="请填写单位"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="数量">
            <template #default="{row}">
              <el-input v-model="row.quantity" placeholder="请填写数量"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单单价">
            <template #default="{row}">
              <el-input v-model="row.listUnitPrice" placeholder="请填写清单单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单合价">
            <template #default="{row}">
              <el-input v-model="row.listTotalPrice" placeholder="请填写清单合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算单价">
            <template #default="{row}">
              <el-input v-model="row.budgetUnitPrice" placeholder="请填写预算单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算合价">
            <template #default="{row}">
              <el-input v-model="row.budgetTotalPrice" placeholder="请填写预算合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            <template #default="{row}">
              <el-input v-model="row.auditUnitPrice" placeholder="请填写审核单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核合价">
            <template #default="{row}">
              <el-input v-model="row.auditTotalPrice" placeholder="请填写审核合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="备注">
            <template #default="{row}">
              <el-input v-model="row.remark" placeholder="请填写备注"></el-input>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100" v-if="!isIndex">
            <template #default="{row}">
              <el-button @click="delCostEquipmentRow(row)" type="text" size="small" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-table class="table" size="small" :data="inputForm.costEquipmentDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="isBuild">
          <el-table-column prop="listNo" header-align="center" align="center" show-overflow-tooltip label="编号">
         
          </el-table-column>
          <el-table-column prop="listName" header-align="center" align="center" show-overflow-tooltip label="清单名称">
         
          </el-table-column>
          <el-table-column prop="brandModel" header-align="center" align="center" show-overflow-tooltip label="品牌与型号">
          
          </el-table-column>
          <el-table-column prop="unit" header-align="center" align="center" show-overflow-tooltip label="单位">
            
          </el-table-column>
          <el-table-column prop="quantity" header-align="center" align="center" show-overflow-tooltip label="数量">
         
          </el-table-column>
          <el-table-column prop="listUnitPrice" header-align="center" align="center" show-overflow-tooltip label="清单单价">
        
          </el-table-column>
          <el-table-column prop="listTotalPrice" header-align="center" align="center" show-overflow-tooltip label="清单合价">
       
          </el-table-column>
          <el-table-column prop="budgetUnitPrice" header-align="center" align="center" show-overflow-tooltip label="预算单价">
          
          </el-table-column>
          <el-table-column prop="budgetTotalPrice" header-align="center" align="center" show-overflow-tooltip label="预算合价">
          
          </el-table-column>
          <el-table-column prop="auditUnitPrice" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            
          </el-table-column>
          <el-table-column prop="auditTotalPrice" header-align="center" align="center" show-overflow-tooltip label="审核合价">
       
          </el-table-column>
          <el-table-column prop="remark" header-align="center" align="center" show-overflow-tooltip label="备注">
         
          </el-table-column>
    
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="施工工程量清单">
        <div style="margin-bottom: 10px;" v-if="!isIndex">
          <el-button @click="addCostConstructionRow" type="primary" v-if="!isBuild">新增</el-button> <el-button type="primary" @click="handleImport">导入</el-button>
          <el-button type="success" @click="importTemplate">下载模板</el-button>
          <el-button @click="editCostConstructionRow" type="primary" v-if="inputForm.costConstructionDTOList.length>0&&!isBuild">编辑</el-button>
        </div>
        <el-table class="table" size="small" :data="inputForm.costConstructionDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="!isBuild">
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="编号">
            <template #default="{row}">
              <el-input v-model="row.listNo" placeholder="请填写编号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单名称">
            <template #default="{row}">
              <el-input v-model="row.listName" placeholder="请填写清单名称"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单位">
            <template #default="{row}">
              <el-input v-model="row.unit" placeholder="请填写单位"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="数量">
            <template #default="{row}">
              <el-input v-model="row.quantity" placeholder="请填写数量"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单单价">
            <template #default="{row}">
              <el-input v-model="row.listUnitPrice" placeholder="请填写清单单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单合价">
            <template #default="{row}">
              <el-input v-model="row.listTotalPrice" placeholder="请填写清单合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算单价">
            <template #default="{row}">
              <el-input v-model="row.budgetUnitPrice" placeholder="请填写预算单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算合价">
            <template #default="{row}">
              <el-input v-model="row.budgetTotalPrice" placeholder="请填写预算合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            <template #default="{row}">
              <el-input v-model="row.auditUnitPrice" placeholder="请填写审核单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核合价">
            <template #default="{row}">
              <el-input v-model="row.auditTotalPrice" placeholder="请填写审核合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="备注">
            <template #default="{row}">
              <el-input v-model="row.remark" placeholder="请填写备注"></el-input>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100" v-if="!isIndex">
            <template #default="{row}">
              <el-button @click="delCostConstructionRow(row)" type="text" size="small" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-table class="table" size="small" :data="inputForm.costConstructionDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="isBuild">
          <el-table-column prop="listNo" header-align="center" align="center" show-overflow-tooltip label="编号">
            
          </el-table-column>
          <el-table-column prop="listName" header-align="center" align="center" show-overflow-tooltip label="清单名称">
       
          </el-table-column>
          <el-table-column prop="unit" header-align="center" align="center" show-overflow-tooltip label="单位">
        
          </el-table-column>
          <el-table-column prop="quantity" header-align="center" align="center" show-overflow-tooltip label="数量">
       
          </el-table-column>
          <el-table-column prop="listUnitPrice" header-align="center" align="center" show-overflow-tooltip label="清单单价">
          
          </el-table-column>
          <el-table-column prop="listTotalPrice" header-align="center" align="center" show-overflow-tooltip label="清单合价">
        
          </el-table-column>
          <el-table-column prop="budgetUnitPrice" header-align="center" align="center" show-overflow-tooltip label="预算单价">
    
          </el-table-column>
          <el-table-column prop="budgetTotalPrice" header-align="center" align="center" show-overflow-tooltip label="预算合价">
       
          </el-table-column>
          <el-table-column prop="auditUnitPrice" header-align="center" align="center" show-overflow-tooltip label="审核单价">
         
          </el-table-column>
          <el-table-column prop="auditTotalPrice" header-align="center" align="center" show-overflow-tooltip label="审核合价">
          
          </el-table-column>
          <el-table-column prop="remark" header-align="center" align="center" show-overflow-tooltip label="备注">
         
          </el-table-column>
       
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="安全生产费">
        <div style="margin-bottom: 10px;" v-if="!isIndex">
          <el-button @click="addCostSafetyRow" type="primary" v-if="!isBuild">新增</el-button> <el-button type="primary" @click="handleImport">导入</el-button>
          <el-button type="success" @click="importTemplate">下载模板</el-button>
          <el-button @click="editCostSafetyRow" type="primary" v-if="inputForm.costSafetyDTOList.length>0&&!isBuild">编辑</el-button>
        </div>
        <el-table class="table" size="small" :data="inputForm.costSafetyDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="!isBuild">
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="编号">
            <template #default="{row}">
              <el-input v-model="row.listNo" placeholder="请填写编号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="项目名称">
            <template #default="{row}">
              <el-input v-model="row.projectName" placeholder="请填写项目名称"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单位">
            <template #default="{row}">
              <el-input v-model="row.unit" placeholder="请填写单位"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="数量">
            <template #default="{row}">
              <el-input v-model="row.quantity" placeholder="请填写数量"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单价">
            <template #default="{row}">
              <el-input v-model="row.budgetUnitPrice" placeholder="请填写单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="总价">
            <template #default="{row}">
              <el-input v-model="row.budgetTotalPrice" placeholder="请填写总价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            <template #default="{row}">
              <el-input v-model="row.auditUnitPrice" placeholder="请填写审核单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核合价">
            <template #default="{row}">
              <el-input v-model="row.auditTotalPrice" placeholder="请填写审核合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="备注">
            <template #default="{row}">
              <el-input v-model="row.remark" placeholder="请填写备注"></el-input>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100" v-if="!isIndex">
            <template #default="{row}">
              <el-button @click="delCostSafetyRow(row)" type="text" size="small" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-table class="table" size="small" :data="inputForm.costSafetyDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="isBuild">
          <el-table-column prop="listNo" header-align="center" align="center" show-overflow-tooltip label="编号">
        
          </el-table-column>
          <el-table-column prop="projectName" header-align="center" align="center" show-overflow-tooltip label="项目名称">
        
          </el-table-column>
          <el-table-column prop="unit" header-align="center" align="center" show-overflow-tooltip label="单位">
        
          </el-table-column>
          <el-table-column prop="quantity" header-align="center" align="center" show-overflow-tooltip label="数量">
           
          </el-table-column>
          <el-table-column prop="budgetUnitPrice" header-align="center" align="center" show-overflow-tooltip label="单价">
         
          </el-table-column>
          <el-table-column prop="budgetTotalPrice" header-align="center" align="center" show-overflow-tooltip label="总价">
          
          </el-table-column>
          <el-table-column prop="auditUnitPrice" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            
          </el-table-column>
          <el-table-column prop="auditTotalPrice" header-align="center" align="center" show-overflow-tooltip label="审核合价">
     
          </el-table-column>
          <el-table-column prop="remark" header-align="center" align="center" show-overflow-tooltip label="备注">
          
          </el-table-column>
      
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="科研费">
        <div style="margin-bottom: 10px;" v-if="!isIndex">
          <el-button @click="addCostResearchRow" type="primary" v-if="!isBuild">新增</el-button> <el-button type="primary" @click="handleImport">导入</el-button>
          <el-button type="success" @click="importTemplate">下载模板</el-button>
          <el-button @click="editCostResearchRow" type="primary" v-if="inputForm.costResearchDTOList.length>0&&!isBuild">编辑</el-button>
        </div>
        <el-table class="table" size="small" :data="inputForm.costResearchDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%"  v-if="!isBuild">
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="编号">
            <template #default="{row}">
              <el-input v-model="row.listNo" placeholder="请填写编号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="类目名称">
            <template #default="{row}">
              <el-input v-model="row.categoryName" placeholder="请填写类目名称"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单名称">
            <template #default="{row}">
              <el-input v-model="row.listName" placeholder="请填写清单名称"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="品牌与型号">
            <template #default="{row}">
              <el-input v-model="row.brandModel" placeholder="请填写品牌与型号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单位">
            <template #default="{row}">
              <el-input v-model="row.unit" placeholder="请填写单位"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="数量">
            <template #default="{row}">
              <el-input v-model="row.quantity" placeholder="请填写数量"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单单价">
            <template #default="{row}">
              <el-input v-model="row.listUnitPrice" placeholder="请填写清单单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单合价">
            <template #default="{row}">
              <el-input v-model="row.listTotalPrice" placeholder="请填写清单合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算单价">
            <template #default="{row}">
              <el-input v-model="row.budgetUnitPrice" placeholder="请填写预算单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算合价">
            <template #default="{row}">
              <el-input v-model="row.budgetTotalPrice" placeholder="请填写预算合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            <template #default="{row}">
              <el-input v-model="row.auditUnitPrice" placeholder="请填写审核单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核合价">
            <template #default="{row}">
              <el-input v-model="row.auditTotalPrice" placeholder="请填写审核合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="备注">
            <template #default="{row}">
              <el-input v-model="row.remark" placeholder="请填写备注"></el-input>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100" v-if="!isIndex">
            <template #default="{row}">
              <el-button @click="delCostResearchRow(row)" type="text" size="small" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-table class="table" size="small" :data="inputForm.costResearchDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%"  v-if="isBuild">
          <el-table-column prop="listNo" header-align="center" align="center" show-overflow-tooltip label="编号">
           
          </el-table-column>
          <el-table-column prop="categoryName" header-align="center" align="center" show-overflow-tooltip label="类目名称">
          
          </el-table-column>
          <el-table-column prop="listName" header-align="center" align="center" show-overflow-tooltip label="清单名称">
         
          </el-table-column>
          <el-table-column prop="brandModel" header-align="center" align="center" show-overflow-tooltip label="品牌与型号">
       
          </el-table-column>
          <el-table-column prop="unit" header-align="center" align="center" show-overflow-tooltip label="单位">
       
          </el-table-column>
          <el-table-column prop="quantity" header-align="center" align="center" show-overflow-tooltip label="数量">
         
          </el-table-column>
          <el-table-column prop="listUnitPrice" header-align="center" align="center" show-overflow-tooltip label="清单单价">
          
          </el-table-column>
          <el-table-column prop="listTotalPrice" header-align="center" align="center" show-overflow-tooltip label="清单合价">
        
          </el-table-column>
          <el-table-column prop="budgetUnitPrice" header-align="center" align="center" show-overflow-tooltip label="预算单价">
          
          </el-table-column>
          <el-table-column prop="budgetTotalPrice" header-align="center" align="center" show-overflow-tooltip label="预算合价">
     
          </el-table-column>
          <el-table-column prop="auditUnitPrice" header-align="center" align="center" show-overflow-tooltip label="审核单价">
          
          </el-table-column>
          <el-table-column prop="auditTotalPrice" header-align="center" align="center" show-overflow-tooltip label="审核合价">
      
          </el-table-column>
          <el-table-column prop="remark" header-align="center" align="center" show-overflow-tooltip label="备注">
           
          </el-table-column>
 
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="项目管理费">
        <div style="margin-bottom: 10px;" v-if="!isIndex">
          <el-button @click="addCostManagementRow" type="primary" v-if="!isBuild">新增</el-button> <el-button type="primary" @click="handleImport">导入</el-button>
          <el-button type="success" @click="importTemplate">下载模板</el-button>
          <el-button @click="editCostManagementRow" type="primary" v-if="inputForm.costManagementDTOList.length>0&&!isBuild">编辑</el-button>
        </div>
        <el-table class="table" size="small" :data="inputForm.costManagementDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="!isBuild">
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="编号">
            <template #default="{row}">
              <el-input v-model="row.listNo" placeholder="请填写编号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="项目名称">
            <template #default="{row}">
              <el-input v-model="row.listName" placeholder="请填写项目名称"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单位">
            <template #default="{row}">
              <el-input v-model="row.unit" placeholder="请填写单位"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="数量">
            <template #default="{row}">
              <el-input v-model="row.quantity" placeholder="请填写数量"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单价">
            <template #default="{row}">
              <el-input v-model="row.budgetUnitPrice" placeholder="请填写单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="总价">
            <template #default="{row}">
              <el-input v-model="row.budgetTotalPrice" placeholder="请填写总价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            <template #default="{row}">
              <el-input v-model="row.auditUnitPrice" placeholder="请填写审核单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核总价">
            <template #default="{row}">
              <el-input v-model="row.auditTotalPrice" placeholder="请填写审核总价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="备注">
            <template #default="{row}">
              <el-input v-model="row.remark" placeholder="请填写备注"></el-input>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100" v-if="!isIndex">
            <template #default="{row}">
              <el-button @click="delCostManagementRow(row)" type="text" size="small" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-table class="table" size="small" :data="inputForm.costManagementDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="isBuild">
          <el-table-column prop="listNo" header-align="center" align="center" show-overflow-tooltip label="编号">
          
          </el-table-column>
          <el-table-column prop="listName" header-align="center" align="center" show-overflow-tooltip label="项目名称">
        
          </el-table-column>
          <el-table-column prop="unit" header-align="center" align="center" show-overflow-tooltip label="单位">
          
          </el-table-column>
          <el-table-column prop="quantity" header-align="center" align="center" show-overflow-tooltip label="数量">
           
          </el-table-column>
          <el-table-column prop="budgetUnitPrice" header-align="center" align="center" show-overflow-tooltip label="单价">
       
          </el-table-column>
          <el-table-column prop="budgetTotalPrice" header-align="center" align="center" show-overflow-tooltip label="总价">
         
          </el-table-column>
          <el-table-column prop="auditUnitPrice" header-align="center" align="center" show-overflow-tooltip label="审核单价">
         
          </el-table-column>
          <el-table-column prop="auditTotalPrice" header-align="center" align="center" show-overflow-tooltip label="审核总价">
         
          </el-table-column>
          <el-table-column prop="remark" header-align="center" align="center" show-overflow-tooltip label="备注">
            <template #default="{row}">
              <el-input v-model="row.remark" placeholder="请填写备注"></el-input>
            </template>
          </el-table-column>
  
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="其他">
        <div style="margin-bottom: 10px;" v-if="!isIndex">
          <el-button @click="addCostOtherRow" type="primary" v-if="!isBuild">新增</el-button> <el-button type="primary" @click="handleImport">导入</el-button>
          <el-button type="success" @click="importTemplate">下载模板</el-button>
          <el-button @click="editCostEquipmentRow" type="primary" v-if="inputForm.costOtherDTOList&&inputForm.costOtherDTOList.length>0&&!isBuild">编辑</el-button>
        </div>
        <el-table class="table" size="small" :data="inputForm.costOtherDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="!isBuild">
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="编号">
            <template #default="{row}">
              <el-input v-model="row.listNo" placeholder="请填写编号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单名称">
            <template #default="{row}">
              <el-input v-model="row.listName" placeholder="请填写清单名称"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单位">
            <template #default="{row}">
              <el-input v-model="row.unit" placeholder="请填写单位"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="数量">
            <template #default="{row}">
              <el-input v-model="row.quantity" placeholder="请填写数量"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算单价">
            <template #default="{row}">
              <el-input v-model="row.budgetUnitPrice" placeholder="请填写预算单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算合价">
            <template #default="{row}">
              <el-input v-model="row.budgetTotalPrice" placeholder="请填写预算合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            <template #default="{row}">
              <el-input v-model="row.auditUnitPrice" placeholder="请填写审核单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核合价">
            <template #default="{row}">
              <el-input v-model="row.auditTotalPrice" placeholder="请填写审核合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="备注">
            <template #default="{row}">
              <el-input v-model="row.remark" placeholder="请填写备注"></el-input>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100" v-if="!isIndex">
            <template #default="{row}">
              <el-button @click="delCostOtherRow(row)" type="text" size="small" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-table class="table" size="small" :data="inputForm.costOtherDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="isBuild">
          <el-table-column prop="listNo" header-align="center" align="center" show-overflow-tooltip label="编号">
       
          </el-table-column>
          <el-table-column prop="listName" header-align="center" align="center" show-overflow-tooltip label="清单名称">
       
          </el-table-column>
          <el-table-column prop="unit" header-align="center" align="center" show-overflow-tooltip label="单位">
    
          </el-table-column>
          <el-table-column prop="quantity" header-align="center" align="center" show-overflow-tooltip label="数量">
         
          </el-table-column>
          <el-table-column prop="budgetUnitPrice" header-align="center" align="center" show-overflow-tooltip label="预算单价">
      
          </el-table-column>
          <el-table-column prop="budgetTotalPrice" header-align="center" align="center" show-overflow-tooltip label="预算合价">
      
          </el-table-column>
          <el-table-column prop="auditUnitPrice" header-align="center" align="center" show-overflow-tooltip label="审核单价">
  
          </el-table-column>
          <el-table-column prop="auditTotalPrice" header-align="center" align="center" show-overflow-tooltip label="审核合价">
        
          </el-table-column>
          <el-table-column prop="remark" header-align="center" align="center" show-overflow-tooltip label="备注">
       
          </el-table-column>
  
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="技术服务清单">
        <div style="margin-bottom: 10px;" v-if="!isIndex">
          <el-button @click="addCostServiceRow" type="primary" v-if="!isBuild">新增</el-button> <el-button type="primary" @click="handleImport">导入</el-button>
          <el-button type="success" @click="importTemplate">下载模板</el-button>
          <el-button @click="editCostServiceRow" type="primary" v-if="inputForm.costServiceDTOList.length>0&&!isBuild">编辑</el-button>
        </div>
        <el-table class="table" size="small" :data="inputForm.costServiceDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="!isBuild">
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="编号">
            <template #default="{row}">
              <el-input v-model="row.listNo" placeholder="请填写编号"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单名称">
            <template #default="{row}">
              <el-input v-model="row.listName" placeholder="请填写清单名称"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="单位">
            <template #default="{row}">
              <el-input v-model="row.unit" placeholder="请填写单位"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="数量">
            <template #default="{row}">
              <el-input v-model="row.quantity" placeholder="请填写数量"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单单价">
            <template #default="{row}">
              <el-input v-model="row.listUnitPrice" placeholder="请填写清单单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="清单合价">
            <template #default="{row}">
              <el-input v-model="row.listTotalPrice" placeholder="请填写清单合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算单价">
            <template #default="{row}">
              <el-input v-model="row.budgetUnitPrice" placeholder="请填写预算单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="预算合价">
            <template #default="{row}">
              <el-input v-model="row.budgetTotalPrice" placeholder="请填写预算合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核单价">
            <template #default="{row}">
              <el-input v-model="row.auditUnitPrice" placeholder="请填写审核单价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="审核合价">
            <template #default="{row}">
              <el-input v-model="row.auditTotalPrice" placeholder="请填写审核合价"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="" header-align="center" align="center" show-overflow-tooltip label="备注">
            <template #default="{row}">
              <el-input v-model="row.remark" placeholder="请填写备注"></el-input>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100" v-if="!isIndex">
            <template #default="{row}">
              <el-button @click="delCostConstructionRow(row)" type="text" size="small" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-table class="table" size="small" :data="inputForm.costServiceDTOList.filter((item) => { return item.delFlag !== '1'})" style="width: 100%" v-if="isBuild">
          <el-table-column prop="listNo" header-align="center" align="center" show-overflow-tooltip label="编号">
            
          </el-table-column>
          <el-table-column prop="listName" header-align="center" align="center" show-overflow-tooltip label="清单名称">
       
          </el-table-column>
          <el-table-column prop="unit" header-align="center" align="center" show-overflow-tooltip label="单位">
        
          </el-table-column>
          <el-table-column prop="quantity" header-align="center" align="center" show-overflow-tooltip label="数量">
       
          </el-table-column>
          <el-table-column prop="listUnitPrice" header-align="center" align="center" show-overflow-tooltip label="清单单价">
          
          </el-table-column>
          <el-table-column prop="listTotalPrice" header-align="center" align="center" show-overflow-tooltip label="清单合价">
        
          </el-table-column>
          <el-table-column prop="budgetUnitPrice" header-align="center" align="center" show-overflow-tooltip label="预算单价">
    
          </el-table-column>
          <el-table-column prop="budgetTotalPrice" header-align="center" align="center" show-overflow-tooltip label="预算合价">
       
          </el-table-column>
          <el-table-column prop="auditUnitPrice" header-align="center" align="center" show-overflow-tooltip label="审核单价">
         
          </el-table-column>
          <el-table-column prop="auditTotalPrice" header-align="center" align="center" show-overflow-tooltip label="审核合价">
          
          </el-table-column>
          <el-table-column prop="remark" header-align="center" align="center" show-overflow-tooltip label="备注">
         
          </el-table-column>
       
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </el-form>

  <!-- 用户导入对话框 -->
  <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>

    <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url" :data="{
							projectCost: JSON.stringify(inputForm),
						}" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
      <el-icon class="el-icon--upload"><upload-filled /></el-icon>
      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
      <template #tip>
        <div class="el-upload__tip text-center">
          <span>仅允许导入xls、xlsx格式文件。</span>
          <!-- <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link> -->
        </div>
      </template>
    </el-upload>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </template>
  </el-dialog>

  
</template>

<script>
import GridSelect from '@/components/gridSelect'
import projectCostService from '@/api/cost/projectCostService'
import projectMainService from '@/api/project/projectMainService'
import tool from "@/utils/tool";
import sysConfig from "@/config";
export default {
  props: ['projectId', 'formData','costId','isBuild','isIndex'],
  data() {
    return {
      title: '',
      method: '',
      visible: false,
      loading: false,
      projectCostTab: '0',
      projectMainService: projectMainService,
      inputForm: {
        id: '',
        costEquipmentDTOList: [],
        costConstructionDTOList: [],
        costServiceDTOList:[],
        costSafetyDTOList: [],
        costResearchDTOList: [],
        costManagementDTOList: [],
        costOtherDTOList: [],
        project: {
          id: ''
        },
        contractAmt: '',
        auditContractAmt: '',
        unForeseenExpenses: '',
        auditUnForeseenExpenses: '',
        winningServiceFee: '',
        auditWinningServiceFee: '',
        biddingDocumentFee: '',
        auditBiddingDocumentFee: '',
        equipmentCost: '',
        auditEquipmentCost: '',
        constructionCost: '',
        auditConstructionCost: '',
        engineeringInsurance: '',
        auditEngineeringInsurance: '',
        safetyProductionCost: '',
        auditSafetyProductionCost: '',
        researchFunding: '',
        auditResearchFunding: '',
        personnelManagementFee: '',
        auditPersonnelManagementFee: '',
        otherManagementFee: '',
        auditOtherManagementFee: '',
        miscellaneous: '',
        auditMiscellaneous: '',
        taxes: '',
        auditTaxes: ''
      },
      projectCost:{},
      /*** 用户导入参数 */
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Token: tool.data.get(sysConfig.TOKEN) },
        // 上传的地址
        url: this.$http.BASE_URL + "/cost/projectCost/upload"
      }
    }
  },
  components: {
    GridSelect
  },
  created() {
    if(this.formData&&!this.formData.isPrev){
    this.inputForm=this.deepClone(this.formData)
    this.inputForm.project={id:this.projectId}
    this.inputForm.costEquipmentDTOList = []
        this.inputForm.costConstructionDTOList = []
        this.inputForm.costSafetyDTOList = []
        this.inputForm.costResearchDTOList = []
        this.inputForm.costManagementDTOList = []
        this.inputForm.costOtherDTOList = []
        this.inputForm.costServiceDTOList = []
        
    // {   project: {id: this.projectId},costEquipmentDTOList:this.formData.costEquipmentDTOList,costConstructionDTOList:this.formData.costConstructionDTOList,costSafetyDTOList:this.formData.costSafetyDTOList,costResearchDTOList:this.formData.costResearchDTOList,costManagementDTOList:this.formData.costManagementDTOList,costOtherDTOList:this.formData.costOtherDTOList}
  }
    if(this.costId&&!this.formData.isPrev){
      this.getInfo()
    }
   if(this.formData.isPrev){
    this.inputForm=this.deepClone(this.formData)
   }
  },
  methods: {
    init(method, id) {
      this.method = method
      if (method === 'add') {
        this.title = `新建成本`
      } else if (method === 'edit') {
        this.title = '修改成本'
      } else if (method === 'view') {
        this.title = '查看成本'
      }
      this.visible = true
      this.loading = false
      this.$nextTick(() => {
        this.$refs.inputForm.resetFields()
        this.inputForm.id = id
        this.projectCostTab = '0'
        this.inputForm.costEquipmentDTOList = []
        this.inputForm.costConstructionDTOList = []
        this.inputForm.costSafetyDTOList = []
        this.inputForm.costResearchDTOList = []
        this.inputForm.costManagementDTOList = []
        this.inputForm.costOtherDTOList = []
        this.inputForm.costServiceDTOList= []
        if (method === 'edit' || method === 'view') { // 修改或者查看
          this.loading = true
  
          projectCostService.queryById(this.inputForm.id).then((data) => {
            this.inputForm = { ...this.inputForm,  project: {id: this.projectId},costEquipmentDTOList:data.costEquipmentDTOList,costConstructionDTOList:data.costConstructionDTOList,costServiceDTOList:data.costServiceDTOList,costSafetyDTOList:data.costSafetyDTOList,costResearchDTOList:data.costResearchDTOList,costManagementDTOList:data.costManagementDTOList,costOtherDTOList:data.costOtherDTOList}

            this.loading = false
          })
        }
      })
    },
    getInfo(){
      this.loading = false
      projectCostService.queryById(this.costId).then((data) => {  
            this.inputForm = { ...this.inputForm,  project: {id: this.projectId},costEquipmentDTOList:data.costEquipmentDTOList,costConstructionDTOList:data.costConstructionDTOList,costServiceDTOList:data.costServiceDTOList,costSafetyDTOList:data.costSafetyDTOList,costResearchDTOList:data.costResearchDTOList,costManagementDTOList:data.costManagementDTOList,costOtherDTOList:data.costOtherDTOList}
            this.loading = false

           
          })
    },
    saveCostEquipmentRow(child) {
    
      if (child[0] === '') {
        this.inputForm.costEquipmentDTOList.push(child[1])
      } else {
        this.inputForm.costEquipmentDTOList.forEach((item, index) => {
          if (item === child[0]) {
            this.inputForm.costEquipmentDTOList.splice(index, 1, child[1])
          }
        })
      }
    },
     deepClone(obj) {
  let objClone = Array.isArray(obj) ? [] : {}
  if (obj && typeof obj === 'object') {
    for (var key in obj) {
      if (obj.hasOwnProperty(key)) {
        // 判断ojb子元素是否为对象，如果是，递归复制
        if (obj[key] && typeof obj[key] === 'object') {
          objClone[key] = this.deepClone(obj[key])
        } else {
          // 如果不是，简单复制
          objClone[key] = obj[key]
        }
      }
    }
  }
  return objClone
},

    addCostEquipmentRow() {
      this.inputForm.costEquipmentDTOList.push({
        listNo: '',
        listName: '',
        brandModel: '',
        unit: '',
        quantity: '',
        listUnitPrice: '',
        listTotalPrice: '',
        budgetUnitPrice: '',
        budgetTotalPrice: '',
        auditUnitPrice: '',
        auditTotalPrice: '',
        remark: ''
      })
    },
    editCostEquipmentRow() {

    },
    delCostEquipmentRow(child) {
      this.inputForm.costEquipmentDTOList.forEach((item, index) => {
        if (item === child && item.id === '') {
          this.inputForm.costEquipmentDTOList.splice(index, 1)
        } else if (item === child) {
          item.delFlag = '1'
          this.inputForm.costEquipmentDTOList.splice(index, 1, item)
        }
      })
    },
    saveCostConstructionRow(child) {
      if (child[0] === '') {
        this.inputForm.costConstructionDTOList.push(child[1])
      } else {
        this.inputForm.costConstructionDTOList.forEach((item, index) => {
          if (item === child[0]) {
            this.inputForm.costConstructionDTOList.splice(index, 1, child[1])
          }
        })
      }
    },
    addCostConstructionRow() {
      this.inputForm.costConstructionDTOList.push({
        listNo: '',
        listName: '',
        unit: '',
        quantity: '',
        listUnitPrice: '',
        listTotalPrice: '',
        budgetUnitPrice: '',
        budgetTotalPrice: '',
        auditUnitPrice: '',
        auditTotalPrice: '',
        remark: ''
      })
    },
    delCostConstructionRow(child) {
      this.inputForm.costConstructionDTOList.forEach((item, index) => {
        if (item === child && item.id === '') {
          this.inputForm.costConstructionDTOList.splice(index, 1)
        } else if (item === child) {
          item.delFlag = '1'
          this.inputForm.costConstructionDTOList.splice(index, 1, item)
        }
      })
    },

    saveCostServiceRow(child) {
      if (child[0] === '') {
        this.inputForm.costServiceDTOList.push(child[1])
      } else {
        this.inputForm.costServiceDTOList.forEach((item, index) => {
          if (item === child[0]) {
            this.inputForm.costServiceDTOList.splice(index, 1, child[1])
          }
        })
      }
    },
    addCostServiceRow() {
      this.inputForm.costServiceDTOList.push({
        listNo: '',
        listName: '',
        unit: '',
        quantity: '',
        listUnitPrice: '',
        listTotalPrice: '',
        budgetUnitPrice: '',
        budgetTotalPrice: '',
        auditUnitPrice: '',
        auditTotalPrice: '',
        remark: ''
      })
    },
    delCostServiceRow(child) {
      this.inputForm.costServiceDTOList.forEach((item, index) => {
        if (item === child && item.id === '') {
          this.inputForm.costServiceDTOList.splice(index, 1)
        } else if (item === child) {
          item.delFlag = '1'
          this.inputForm.costServiceDTOList.splice(index, 1, item)
        }
      })
    },


    saveCostSafetyRow(child) {
      if (child[0] === '') {
        this.inputForm.costSafetyDTOList.push(child[1])
      } else {
        this.inputForm.costSafetyDTOList.forEach((item, index) => {
          if (item === child[0]) {
            this.inputForm.costSafetyDTOList.splice(index, 1, child[1])
          }
        })
      }
    },
    addCostSafetyRow() {
      this.inputForm.costSafetyDTOList.push({
        listNo: '',
        projectName: '',
        unit: '',
        quantity: '',
        budgetUnitPrice: '',
        budgetTotalPrice: '',
        auditUnitPrice: '',
        auditTotalPrice: '',
        remark: ''
      })
    },
    delCostSafetyRow(child) {
      this.inputForm.costSafetyDTOList.forEach((item, index) => {
        if (item === child && item.id === '') {
          this.inputForm.costSafetyDTOList.splice(index, 1)
        } else if (item === child) {
          item.delFlag = '1'
          this.inputForm.costSafetyDTOList.splice(index, 1, item)
        }
      })
    },
    saveCostResearchRow(child) {
      if (child[0] === '') {
        this.inputForm.costResearchDTOList.push(child[1])
      } else {
        this.inputForm.costResearchDTOList.forEach((item, index) => {
          if (item === child[0]) {
            this.inputForm.costResearchDTOList.splice(index, 1, child[1])
          }
        })
      }
    },
    addCostResearchRow() {
      this.inputForm.costResearchDTOList.push({
        listNo: '',
        categoryName: '',
        listName: '',
        brandModel: '',
        unit: '',
        quantity: '',
        listUnitPrice: '',
        listTotalPrice: '',
        budgetUnitPrice: '',
        budgetTotalPrice: '',
        auditUnitPrice: '',
        auditTotalPrice: '',
        remark: ''
      })
    },
    delCostResearchRow(child) {
      this.inputForm.costResearchDTOList.forEach((item, index) => {
        if (item === child && item.id === '') {
          this.inputForm.costResearchDTOList.splice(index, 1)
        } else if (item === child) {
          item.delFlag = '1'
          this.inputForm.costResearchDTOList.splice(index, 1, item)
        }
      })
    },
    saveCostManagementRow(child) {
      if (child[0] === '') {
        this.inputForm.costManagementDTOList.push(child[1])
      } else {
        this.inputForm.costManagementDTOList.forEach((item, index) => {
          if (item === child[0]) {
            this.inputForm.costManagementDTOList.splice(index, 1, child[1])
          }
        })
      }
    },
    addCostManagementRow() {
      this.inputForm.costManagementDTOList.push({
        listNo: '',
        listName: '',
        unit: '',
        quantity: '',
        budgetUnitPrice: '',
        budgetTotalPrice: '',
        auditUnitPrice: '',
        auditTotalPrice: '',
        remark: ''
      })
    },
    delCostManagementRow(child) {
      this.inputForm.costManagementDTOList.forEach((item, index) => {
        if (item === child && item.id === '') {
          this.inputForm.costManagementDTOList.splice(index, 1)
        } else if (item === child) {
          item.delFlag = '1'
          this.inputForm.costManagementDTOList.splice(index, 1, item)
        }
      })
    },
    saveCostOtherRow(child) {
      if (child[0] === '') {
        this.inputForm.costOtherDTOList.push(child[1])
      } else {
        this.inputForm.costOtherDTOList.forEach((item, index) => {
          if (item === child[0]) {
            this.inputForm.costOtherDTOList.splice(index, 1, child[1])
          }
        })
      }
    },
    addCostOtherRow() {
      this.inputForm.costOtherDTOList.push({
        listNo: '',
        listName: '',
        unit: '',
        quantity: '',
        budgetUnitPrice: '',
        budgetTotalPrice: '',
        auditUnitPrice: '',
        auditTotalPrice: '',
        remark: ''
      })
    },
    delCostOtherRow(child) {
      this.inputForm.costOtherDTOList.forEach((item, index) => {
        if (item === child && item.id === '') {
          this.inputForm.costOtherDTOList.splice(index, 1)
        } else if (item === child) {
          item.delFlag = '1'
          this.inputForm.costOtherDTOList.splice(index, 1, item)
        }
      })
    },
    nextCost() {
      return new Promise((resolve, reject) => {
        try {
          this.loading = true;
        //  , ...this.formData
          this.inputForm = { ...this.inputForm ,status:this.isBuild?2:1}
          this.inputForm.project.id = this.projectId;
          projectCostService.nextCost(this.inputForm).then((data) => {
            this.loading = false
            resolve(data);
          }).catch((error) => {
            this.loading = false
            reject(error);
          })
        } catch (error) {
          this.loading = false
          reject(error);
        }
      });
    },
    // 表单提交
    saveSubmit() {
      return new Promise((resolve, reject) => {
        try {

   
          this.loading = true;
          this.inputForm.project.id = this.projectId;
          this.inputForm = { ...this.inputForm, ...this.formData }

          projectCostService.save(this.inputForm).then((data) => {
            this.loading = false
            resolve();
          }).catch((error) => {
            this.loading = false
            reject(error);
          })
        } catch (error) {
          this.loading = false
          reject(error);
        }
      });
    },

    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      if(this.costId){
      projectCostService
        .exportDetail({id:this.costId})
        .then((data) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadExcel(data, "造价审核下载");
          this.loading = false
        })
        .catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response);
          }
        });
      
      }else{
        projectCostService
        .downTemplate()
        .then((data) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadExcel(data, "成本预算模板");
          this.loading = false
        })
        .catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response);
          }
        });
      }
   
    
   



     
    },
    /**文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.uploadRef.handleRemove(file);
      this.inputForm.costEquipmentDTOList=response.costEquipmentDTOList;
      this.inputForm.costConstructionDTOList=response.costConstructionDTOList;
      this.inputForm.costSafetyDTOList=response.costSafetyDTOList;
      this.inputForm.costResearchDTOList=response.costResearchDTOList;
      this.inputForm.costManagementDTOList=response.costManagementDTOList;
      this.inputForm.costOtherDTOList=response.costOtherDTOList;
      this.inputForm.costServiceDTOList=response.costServiceDTOList;
      this.$message.success({
					dangerouslyUseHTMLString: true,
					message:"上传成功",
				});
  
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.uploadRef.submit();
    },
    getInputFormData() {
      let data={...this.formData,costEquipmentDTOList:this.inputForm.costEquipmentDTOList,costConstructionDTOList:this.inputForm.costConstructionDTOList,costServiceDTOList:this.inputForm.costServiceDTOList,costSafetyDTOList:this.inputForm.costSafetyDTOList,costResearchDTOList:this.inputForm.costResearchDTOList,costManagementDTOList:this.inputForm.costManagementDTOList,costOtherDTOList:this.inputForm.costOtherDTOList};
  
      return data
    },
   handleClick(val){
    this.$emit('tab-change', val.props.label)
   }
  }
}
</script>

  